﻿using Architecture.Api.Application.Command.RoleCommand;
using Architecture.Service;
using MediatR;
using Architecture.Domain;
using Architecture.Domain.RBAC;

namespace Architecture.Api.Application.CommandHandlers.RoleHandler
{
    public class RoleUpdateCommandHandler : IRequestHandler<RoleUpdateCommand, int>
    {
        protected readonly IRoleService _roleService;

        public RoleUpdateCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }

        public async Task<int> Handle(RoleUpdateCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.UpdateAsync(new Role() {RoleId=request.RoleId, RoleName = request.RoleName,AddName=request.AddName,AddTime=request.AddTime });
        }
    }
}
